package se.ramfelt.psn.model;

import java.util.Comparator;

/**
 * Comparator for Friend class that orders friends according to their presence
 * and the their names.
 */
public class FriendComparator implements Comparator<Friend> {

    public int compare(Friend arg0, Friend arg1) {
        if (arg0.getPresence().equals(arg1.getPresence())) {
            return arg0.getOnlineId().compareTo(arg1.getOnlineId());
        }
        return arg0.getPresence().compareTo(arg1.getPresence());
    }

}
